<?php

require_once('../include/GeneralTop.php');
require('../include/class/db.php');
require('../include/class/pagination.php');
require('../include/simpleHeader.php');

?>

<body topmargin="0" leftmargin="0">
<table width="777" border="0" align="left" cellpadding="0" cellspacing="0" valign="top">
  <tr>
    <td width="777" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="51" valign="top" background="../images/fen_09.gif"><table width="95%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="16">&nbsp;</td>
            </tr>
          </table>
          <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="14"><img src="../images/fen_12.gif" width="7" height="29"></td>
              <td width="405"><span class="font_16px_black_B"><?php echo TEXT_INFO_SEARCH?></span></td>
              <td width="15">&nbsp;</td>
              <td width="299">&nbsp;</td>
              </tr>
          </table></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="1" bgcolor="#767676"></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="8"></td>
        </tr>
      </table>
      <form id="form1" name="form1" method="get" action="<?php echo $_SERVER['PHP_SELF']?>">
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="font_12px_gray">
        <tr>
          <td valign="top" class="font_12px_gray">
          <table border="0" align="left" cellpadding="7" cellspacing="1" class="font_12px_gray">
        <tr>
          <td align="right" width="80" class="font_12px_gray_h18"><strong><?php echo TEXT_HOSPITAL_NAME?>：</strong></td>
          <td align="left" class="font_12px_gray_h18"><input type="text" name="hosname" size="20"></td>
          <td align="right" width="60" class="font_12px_gray_h18"><strong><?php echo TEXT_VETERINARY_CITY?>：</strong></td>
          <td align="left" class="font_12px_gray_h18"><select name="city" id="city"><option value="上海市">上海市</option></td>
          <td align="right" width="60" class="font_12px_gray_h18"><strong><?php echo TEXT_VETERINARY_DISTRICT?>：</strong></td>
          <td align="left"><select name="ddlDistrict" id="ddlDistrict">
	        <option value="all"><?php echo TEXT_ALL?></option>
	        <?php
	        foreach($district_arr as $_key => $_value) {
	        	if($_GET['ddlDistrict'] == $_value) {
	        		echo '<option value="'.$_value.'" selected>'.$_value.'</option>';
	        	}
	        	else {
	        		echo '<option value="'.$_value.'">'.$_value.'</option>';
	        	}
	        }        
	        ?>
	      </select>
     	 </td>      
      <td align="right"> 
          <input type="submit" id="submit" name="submit" value="<?php echo TEXT_SEARCH?>" />
	  </td>
    </tr>    
  
    </table>
    </form>
    <tr><td><br></td></tr>
  <?php
  if(isset($_GET['submit'])) {
  ?>
    <tr><td>
      <table width="100%" border="0" align="center" cellpadding="7" cellspacing="1" class="font_12px_gray">
  <tr>
  	<td colspan="7" class="font_12px_green"><?php echo TEXT_WITH_STAR?></td>
  </tr>
  <tr>
    <td align="left"><b><?php echo TEXT_HOSPITAL_NAME?></b></td>
    <!--<td align="left"><b><?php echo TEXT_HOSPITAL_CITY?></b></td>-->
    <td align="left"><b><?php echo TEXT_HOSPITAL_DISTRICT?></b></td>
    <td align="left"><b><?php echo TEXT_HOSPITAL_ADDRESS?></b></td>
    <td align="left"><b><?php echo TEXT_HOSPITAL_PHONE?></b></td>
    <!--<td align="left"><b><?php echo TEXT_HOSPITAL_CELL?></b></td>-->
    <td align="left"><b><?php echo TEXT_HOSPITAL_MAINCONTACT?></b></td>
  </tr>
  <?php  
	  if('all' == $_GET['ddlDistrict']) {
	  	  $districe_where = '';	  	  
	  }
	  else {
	  	  $districe_where =  " and vet_district='".$_GET['ddlDistrict']."'";
	  }
	  
	  $db = new db;
	  //$sql = "SELECT hospital_Id, vet_hospital, vet_city, vet_district, vet_address, vet_phone, vet_maincontact, vet_mobilephone FROM pethospital where vet_hospital like '%".$_GET['hosname']."%' and vet_city='".$_GET['city']."'".$districe_where;
	  $sql = "SELECT hospital_Id, vet_hospital, vet_city, vet_district, vet_address, vet_phone, vet_maincontact, vet_mobilephone, vet_sspca_partner FROM pethospital where vet_hospital like '%".$_GET['hosname']."%' ".$districe_where;
	  $res = $db->query($sql);
	  $num = $db->num($res);
	  if($num > 0) {
		  $pagination = new Pagination($num, PAGICATION_RECORD_COUNT_SEACH_HOSPITAL, $_GET['page'], PAGINATION_DELTA);
		  $sql = $sql." limit ".$pagination->begin.",".$pagination->end;
		  $res = $db->query($sql);
		  $i = 1;
		  while($row = $db->fetch($res)) {
		  	  if($i % 2 == 0) {
				  $bgcolor = '#ffffff';
			  }
			  else {
				  $bgcolor = '#eeeeee';
			  }
			  $i ++;
			  if('Y' == $row['vet_sspca_partner']) {
			  	  $star = '<font color="red">*</font>';
			  }
			  else {
			  	  $star = '';
			  }
  ?>
	    <tr style="background:<?php echo $bgcolor?>">
	      <td><?php echo $star?> <a href="VeterinarySearchinfo.php?Id=<?php echo $row['hospital_Id']; ?>" class="gray_12px"><?php echo $row['vet_hospital']; ?></a></td>
	      <!--<td><?php echo $row['vet_city']; ?></td>-->
	      <td><?php echo $row['vet_district']; ?></td>
	      <td><?php echo $row['vet_address']; ?></td>
	      <td><?php echo $row['vet_phone']; ?></td>
	      <!--<td><?php echo $row['vet_mobilephone']; ?></td>-->
	      <td><?php echo $row['vet_maincontact']; ?></td>
	    </tr>
  <?php
		  }
	  }
  ?>
<tr>
        <td colspan="5">
      <table border="0" align="left" cellpadding="0" cellspacing="5" class="font_12px_gray">
            <tr>
              <td>
              <?php
				if($num > PAGICATION_RECORD_COUNT_SEACH_HOSPITAL) {
					echo $pagination->paginationString;
				}
				?>
              </td>
              </tr>
          </table>      </td></tr>
      
      <tr><td colspan="5">
      </td></tr>
      </table>   
  <?php
  }
  ?>    
          
          </td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="8"></td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>